//
//  HomeViewCell.m
//  Feel_at_home
//
//  Created by dllo on 15/9/24.
//  Copyright © 2015年 Feel_at_home. All rights reserved.
//

#import "HomeViewCell.h"
#import <UIImageView+WebCache.h>
@implementation HomeViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.cover_image_url = [[UIImageView alloc]init];
        [self.contentView addSubview:self.cover_image_url];
        
        self.title = [[UILabel alloc]init];
        [self.contentView addSubview:self.title];
        
        self.likelabel = [[UILabel alloc]init];
        [self.contentView addSubview:self.likelabel];
        
        self.likeview = [[UIView alloc]init];
        [self.contentView addSubview:self.likeview];
        
//        UIView *view = [[UIView alloc]init];
//        view.backgroundColor = [UIColor colorWithRed:0/255.0f green:0/255.0f blue:0/255.0f alpha:0.3];
//        view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width- 8, self.contentView.frame.size.height- 5)];
//        [self.likeview addSubview:view];
    }
    return self;

}
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat w = self.contentView.frame.size.width;
    CGFloat h = self.contentView.frame.size.height;
    
    self.cover_image_url.frame = CGRectMake(5, 5, w- 8, h- 5);
    self.cover_image_url.layer.cornerRadius = 5;//圆角
    self.cover_image_url.layer.masksToBounds = YES;

    
    
    self.title.frame = CGRectMake(5, 150, self.contentView.frame.size.width, 50);
    [self.title setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];
    [self.title setFont:[UIFont fontWithName:@"Helvetica-BoldOblique" size:20]];
    self.title.numberOfLines = 0;
    self.title.textAlignment = NSTextAlignmentCenter;
    self.title.textColor = [UIColor whiteColor];
    
    self.likeview.frame = CGRectMake(5, 5, w- 8, h- 5);
    self.likeview.backgroundColor = [UIColor colorWithRed:0/255.0f green:0/255.0f blue:0/255.0f alpha:0.1];
    self.likeview.layer.cornerRadius = 15;
    self.likeview.layer.masksToBounds = YES;
    
    self.likelabel.frame = CGRectMake(w*0.1, h*0.1, w*0.18, h*0.32);
    [self.likelabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:18]];
    [self.likelabel setFont:[UIFont fontWithName:@"Helvetica-BoldOblique" size:18]];
    
    self.likelabel.textColor = [UIColor whiteColor];
    
}
- (void)setHomemodel:(HomeModel *)homemodel
{
    [self.cover_image_url sd_setImageWithURL:[NSURL URLWithString:homemodel.cover_image_url] placeholderImage:[UIImage imageNamed:@"xinqing.png"]];
    
    self.title.text = homemodel.title;
    
    self.likelabel.text = [NSString stringWithFormat:@"❤️ %@",homemodel.likes_count];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
